<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.*" import="cameraConfig.*" import="java.net.URI;"%>
<%@page language="java" contentType="text/html" pageEncoding="UTF-8"%>
<c:if test="${!user.isLoggedIn() || user.isInactive() || !user.isAdmin()}">
	<c:redirect url="error.jsp"/>
</c:if>

 <jsp:useBean id="camDAO" class="cameraConfig.KameraDAO" scope="session"/>
 	<jsp:setProperty name="camDAO" property="*"/>
 	
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Camera Administration</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/Resources/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/Resources/Styles/back.css">
    <script src="${pageContext.request.contextPath}/Resources/Scripts/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/Resources/Scripts/script.js"></script>
    <script src="${pageContext.request.contextPath}/Resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
</head>
<body>
	<c:if test="${!empty errorMessage}">
		<center>
			<font color="red">
				<b>
				An Error occurred!
				<br>
				${errorMessage}
				</b>
			</font>
		</center>	
	</c:if>
    <form action="CameraController" name="appform" method="post" id="target" class="form-horizontal">
        <div class="item-active">
            <div class="container">
                <div class="panel active">
                    <ul class="nav nav-tabs nav-pills" id="myTab">
                        <li class=""> <a class="cameraFilter" href="#cameraFilter" data-toggle="tab">Cameras</a>
	                    <li class="active dropdown">
	                         <a class="dropdown-toggle" data-toggle="dropdown">Management<span class="caret"></span></a>
	                         <ul class="dropdown-menu" role="menu">
	                            <li><a class="addUser" href="#addUser" data-toggle="tab">Add New user</a></li>
	                            <li><a class="showUsers" href="#ShowUsers" data-toggle="tab">Show User List</a></li>
	                            <li><a class="addCamera" href="#AddCamera" data-toggle="tab">Camera Management</a></li>
	                         </ul>
	                    </li>
                        <li class=""> <a href="#" data-toggle="tab">About</a>
                        <li class="pull-right"> <a class="logout" href="#" data-toggle="tab">Logout</a>
                    </ul>
                    <br>
                    <div class="tab-content" style="width: 90%; margin-left: 60px">
                        <div class="row">
                            <fieldset>
                                <div class="form-group">
                                    <table class="table borderless">
                                        <tbody>
	                                        <c:forEach var="location" items="${camsByLocation}">
			                                    <tr>
			                                       	<td><b><c:out value="${location.key.getName()}" /></b></td>
			                                        <td></td>
			                                        <td><b><c:out value="${location.key.getBeschreibung()}" /></b></td>
			                                        <td><button name="UserActionButton" value="locEditBtn_${location.key.getName()}" type="submit" class="glyphicon glyphicon-pencil"></button></td>
			                                 	</tr>
			                                 	   										
											    <c:forEach var="cam" items="${location.value}">
											    	<tr>
	                                             		<td></td>
	                                             		<td><c:out value="${cam.getName()}" /></td>
	                                             		<td><c:out value="${cam.getBeschreibung()}" /></td>
	                                             		<td><button name="UserActionButton" value="camEditBtn_${cam.getCamID()}" type="submit" class="glyphicon glyphicon-pencil"></button></td>
	                                             	</tr>   
											    </c:forEach>
											    <tr>
           									    	<td></td>
           									    	<td><i>Add new camera</i></td>
           									    	<td><i>New camera</i></td>
           									    	<td><button name="UserActionButton" value="camNewBtn_${location.key.getName()}" type="submit" class="glyphicon glyphicon-plus"></button></td>
           									    </tr>
											</c:forEach>                                                                                
               							    <tr>
            									<td><b><i>Add new location</i></b></td>
            									<td></td>
            									<td><b><i>New location</i></b></td>
            									<td><button name="UserActionButton" value="locNewBtn" type="submit" class="glyphicon glyphicon-plus"></button></td>
            								</tr>
                                        </tbody>
                                    </table>
                                </div>
                            </fieldset>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</body>
</html>
